package com.et114.modules.msg.service;

import com.et114.components.simpletable.DataList;
import com.et114.core.utility.DateUtil;
import com.et114.modules.msg.dao.IPub_MessageDao;
import com.et114.modules.msg.vo.MsgVO;

/**
 * @author zhiweip
 * @version 1.0
 * @created 16-十二月-2010 13:51:42
 */
public class Pub_MessageServiceImp implements IPub_MessageService {

	private IPub_MessageDao messageDao;
	
	public Pub_MessageServiceImp(){

	}

	public void finalize() throws Throwable {

	}

	public void setMessageDao ( IPub_MessageDao messageDao ) {
		this.messageDao = messageDao;
	}

	public Integer insertMsgInfo ( MsgVO vo ) {
		
		return messageDao.insertMsgInfo ( vo );
	}

	public MsgVO loadMsg ( MsgVO vo ) {
		vo.setReadflag ( "1" );
		messageDao.updateMsgInfo ( vo );
		return messageDao.loadMsg ( vo );
	}

	public DataList queryMsgDataList ( MsgVO vo ) throws Exception {
		
		return messageDao.queryMsgDataList ( vo );
	}

	public int updateMsgInfo ( MsgVO vo ,String mid[]) {
		for(String m:mid){
			if(vo.getOperType ( ).equals ( "del" )){
				vo.setDeleteflag ( "1" );
			}else{
			 vo.setReadflag ( "1" );
			 vo.setReadtime ( DateUtil.getDateOutUSA ( null , true ) );
			}
			 vo.setMid ( new Integer(m) );
			 messageDao.updateMsgInfo ( vo );
		}
		return 0;
	}
	
	public Long countNoread_PUB_MESSAGE(MsgVO vo){
		return messageDao.countNoread_PUB_MESSAGE ( vo );
	}

}